//package com.itheima.tlias84.aspect;
//
//import com.alibaba.fastjson.JSONObject;
//import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
//import com.itheima.tlias84.service.impl.LoginServiceImpl;
//import com.itheima.tlias84.utils.JwtUtil;
//import jakarta.annotation.Resource;
//import jakarta.servlet.http.HttpServletRequest;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDateTime;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Objects;
//
///**
// * 统计接口耗时的切面
// */
//@Slf4j
//@Aspect
//@Component
//public class CountTimeAspect {
//
//    @Resource
//    HttpServletRequest request;
//    @Resource
//    LoginServiceImpl loginService;
//
//    @Around("execution( * com.itheima.tlias84.service.impl.*.*(..))")
//    public Object count(ProceedingJoinPoint point) {
////        Log list = new Log();
//        String token = request.getHeader("token");
//        if (Objects.nonNull(token)) {
//            JSONObject jsonObject = JwtUtil.verifyToken(token);
//            String username = jsonObject.getString("username");
////            list.setOperateEmpName(username);
//            log.info("操作人是{}", username);
//        }
//        Object[] args = point.getArgs();
////        list.setMethodParams(Arrays.toString(args));
//        log.info("请求参数是{}", args);
//        Object target = point.getTarget();
////        list.setClassName((String) target);
//        log.info("获取类名{}", target);
//        LocalDateTime now = LocalDateTime.now();
////        list.setOperateTime(String.valueOf(now));
//        long start = System.currentTimeMillis();
//        //执行父类方法
//        try {
//            Object proceed = point.proceed();
////            list.setReturnValue((String) proceed);
//            log.info("获取返回值{}", proceed);
//            long end = System.currentTimeMillis() - start;
////            list.setCostTime((int) end);
////            list.setMethodName(point.getSignature().getName());
//            log.info("{}接口执行时间为{}", point.getSignature().getName(), end);
////            loginService.insertLog(list);
//            return proceed;
//        } catch (Throwable e) {
//            throw new RuntimeException(e);
//        }
//
//    }
//
//}
